<include file="Public/head"/>
<script type="text/javascript" src="{:get_style_cdnurl()}paimai/yunying/js/jquery.form.js"></script>
<style type="text/css">

    .carousel table tr, td {
        height: 40px;
        line-height: 40px;
        text-align: left;
        border: none;
    }

    #city, #index_type {
        -moz-appearance: none;
        background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;
        border: 1px solid #d7d7d7;
        color: #666;
        float: left;
        font-family: "微软雅黑";
        font-size: 12px;
        height: 26px;
        line-height: 26px;
        margin: 0 10px 10px 0;
        text-align: left;
        width: 154px;
    }

    .carousel_sub input {
        background: #20ab4f none repeat scroll 0 0;
        border: 1px solid #20ab4f;
        border-radius: 3px;
        color: #fff;
        cursor: pointer;
        font-size: 14px;
        height: 30px;
        line-height: 30px;
        margin: 30px 10px;
        text-align: center;
        width: 170px;
    }


</style>
</head>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="clcwht.yhwjgl"/>

    <div class="mianR">
        <div class="add_page">
            <h3 class="cha">编辑摇号文件</h3>
            <div class='carousel'>
                <table width="100%">
                    <tr>
                        <td style="text-align:right">* 标题：</td>
                        <td style="padding:5px 10px;">
                            <input type="text" name="title" placeholder="请输入标题" value="{$detail.title}"
                                   style="width:300px;height:30px;line-height:30px;border:1px solid #ededee;padding-left:5px;">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right">* 城市：</td>
                        <td style="padding:5px 10px;">
                            <select name="city" id="city">
                                <option value="">请选择城市</option>
                                <foreach name="lot_number_city_list" item="cl" key="k">
                                    <option value="{$k}"
                                    <?php echo $detail['city_code']==$k?'selected':'';?>>{$cl}</option>
                                </foreach>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:right">* 指标类型：</td>
                        <td style="padding:5px 10px;">
                            <select name="index_type" id="index_type">
                                <option value="">请选择指标类型</option>
                                <option value="1"
                                <?php echo $detail['index_type']==1?'selected':'';?>>个人普通</option>
                                <option value="2"
                                <?php echo $detail['index_type']==2?'selected':'';?>>个人新能源</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" style="text-align:right">*PDF文件URL：</td>
                        <td width="80%" style="padding:5px 10px;">
                            <input type="text" name="file_url" value="{$detail.url}" placeholder="请填写PDF文件URL"
                                   style="width:300px;height:30px;line-height:30px;border:1px solid #ededee;padding-left:5px;">
                            后缀必须为.PDF
                        </td>
                    </tr>

                    <tr>
                        <td style="text-align:right">备注：</td>
                        <td style="padding:5px 10px;">
                            <input type="text" name="remark" placeholder="非必填项" value="{$detail.remark}"
                                   style="width:300px;height:30px;line-height:30px;border:1px solid #ededee;padding-left:5px;">
                        </td>
                    </tr>
                </table>

                <div class='carousel_sub'>
                    <input type="hidden" name="id" value="{$detail.id}"/>
                    <input type="button" value="确定" name="submit" id="submit">
                    <input type="button" value="取消" name="cancel">
                </div>
            </div>
            <div class="yunBei" style="z-index:999998"></div>
        </div>
    </div>
    <div class="clear"></div>
</div>

<script type="text/javascript">
    /**
     * 确定编辑提交
     */
    $("input[name='submit']").click(function () {
        var lot_id = $("input[name='id']").val();
        var title = $("input[name='title']").val();
        if (title == '') {
            shibai_alert('请填写标题');
            return false;
        }
        var city = $("#city").val();
        if (city == '') {
            shibai_alert('请选择城市');
            return false;
        }
        var index_type = $("#index_type").val();
        if (index_type == '') {
            shibai_alert('请选择指标类型');
            return false;
        }
        var url_reg = /^((https|http)?:\/\/)[^\s]+(\.pdf)/;
        var file_url = $("input[name='file_url']").val();
        if (file_url == '') {
            shibai_alert('请填写文件URL');
            return false;
        }
        if (!url_reg.test(file_url)) {
            shibai_alert('文件URL格式不正确');
            return false;
        }
        var remark = $("input[name='remark']").val();
        var post_params = {
            "lot_id": lot_id,
            'title': title,
            'city': city,
            'index_type': index_type,
            'file_url': file_url,
            'remark': remark
        };
        $.post("/LotNumberFile/editLotNumberFile", post_params, function (data) {
            if (data.code == 200) {
                btn_alert(data.msg);
                setTimeout(function () {
                    window.location.href = "/LotNumberFile/index";
                }, 2000);
            } else {
                shibai_alert(data.msg);
            }
        }, "JSON")
    });
    /**
     * 取消添加
     */
    $("input[name='cancel']").click(function () {
        window.history.back();
    });
</script>

<include file="Public/foot"/>
